﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Xml;
using Microsoft.Kinect;
using Microsoft.Samples.Kinect.KinectExplorer;
using Microsoft.Samples.Kinect.WpfViewers;

namespace ZeroTouchUI
{
    public class NewGestureRecorder : Window
    {
        private readonly GR3 gr3;
        private KinectSensor kinect;
        public NewMainWindow mainWindow;

        public Gesture gesture, oldGesture = null;

        public event SavedEventHandler Saved;
        public virtual void OnSaved(EventArgs e)
        {
            if (Saved != null)
                Saved(this, e);
        }

        public NewGestureRecorder()
        {
        }

        public NewGestureRecorder(NewMainWindow nmw)
        {
            gesture = new Gesture();
            this.gr3 = new GR3 { mainWindow = nmw };
            Initialize();
        }

        public NewGestureRecorder(NewMainWindow nmw, Gesture g)
        {
            gesture = g;
            oldGesture = g;
            this.gr3 = new GR3(gesture) { mainWindow = nmw };
            Initialize();
        }

        private void Initialize()
        {
            Content = this.gr3;
            Width = 715;
            Height = 670;
            MinHeight = 400;
            MinWidth = 400;
            Title = "Gesture Recorder";
            this.Closed += new EventHandler(GestureRecorder_Closed);            
        }

        public KinectSensor Kinect
        {
            get
            {
                return this.kinect;
            }

            set
            {
                this.kinect = value;
                this.gr3.Kinect = this.kinect;
            }
        }

        private void GestureRecorder_Closed(object sender, EventArgs e)
        {
            this.Kinect = null;
        }
    }
}
